home *** CD-ROM | disk | FTP | other *** search
/ Champak 109 / Vol 109.iso / games / chicken_.swf / scripts / frame_4 / DoAction.as
Text File  |  2008-11-12  |  3KB  |  135 lines

  1. function initMeat()
  2. {
  3.    i = 0;
  4.    while(i < 5)
  5.    {
  6.       var obj = this["meat_" + i];
  7.       this["as_" + i].num = i;
  8.       obj.num = i;
  9.       obj.click = true;
  10.       obj.onPress = function()
  11.       {
  12.          if(this.click)
  13.          {
  14.             _root["as_" + this.num].stop();
  15.             this._root.depths += _root.depths <= _root.depthsMax ? 1 : -1000;
  16.             this.swapDepths(_root.depths);
  17.             this.startDrag();
  18.             _root.changeSide(this.num);
  19.             _root.showRipe(this.num);
  20.          }
  21.       };
  22.       obj.onRelease = function()
  23.       {
  24.          if(this.click)
  25.          {
  26.             this.stopDrag();
  27.             if(_root.hit_fire.hitTest(this._x,this._y,true))
  28.             {
  29.                _root.setSite(this.num,this._x,this._y);
  30.                _root.showDirection(this.num);
  31.                _root["as_" + this.num].play();
  32.                _root.sound_mc.gotoAndPlay(2);
  33.             }
  34.             else if(_root.hit_dish.hitTest(this._x,this._y,true))
  35.             {
  36.                this.click = false;
  37.                _root.setSite(this.num,this._x,this._y);
  38.                _root.showDirection(this.num);
  39.                _root["as_" + this.num].gotoAndPlay("ok");
  40.             }
  41.             else
  42.             {
  43.                _root.getSite(this.num);
  44.             }
  45.          }
  46.       };
  47.       var direction = random(2) + 1;
  48.       obj.gotoAndStop(direction);
  49.       obj._visible = true;
  50.       meat_list[i] = new meatClass(direction,obj._x,obj._y);
  51.       i++;
  52.    }
  53. }
  54. function meatClass(direction, x, y)
  55. {
  56.    this.direction = direction;
  57.    this.side = 0;
  58.    this.ripe = [1,1];
  59.    this.count = [0,0];
  60.    this.sx = this.x = x;
  61.    this.sy = this.y = y;
  62.    this.reset = function()
  63.    {
  64.       this.side = 0;
  65.       this.ripe = [1,1];
  66.       this.count = [0,0];
  67.       this.x = this.sx;
  68.       this.y = this.sy;
  69.    };
  70. }
  71. function resetMeat(num)
  72. {
  73.    meat_list[num].reset();
  74.    var obj = this["meat_" + num];
  75.    meat_list[num].direction = random(2) + 1;
  76.    showDirection(num);
  77.    getSite(num);
  78.    obj._visible = true;
  79.    obj.click = true;
  80. }
  81. function changeHP()
  82. {
  83.    HP++;
  84.    hp_mc.gotoAndStop(HP);
  85.    if(HP > 10)
  86.    {
  87.       gotoAndPlay(16);
  88.    }
  89. }
  90. function changeSide(num)
  91. {
  92.    var side = meat_list[num].side;
  93.    side += side <= 0 ? 1 : -1;
  94.    meat_list[num].side = side;
  95. }
  96. function changeDirection(num)
  97. {
  98.    var direction = meat_list[num].direction;
  99.    direction += direction <= 1 ? 1 : -1;
  100.    meat_list[num].direction = direction;
  101.    return direction;
  102. }
  103. function getRipe(num)
  104. {
  105.    var side = meat_list[num].side;
  106.    var ripe = meat_list[num].ripe[side];
  107.    var frame = side * 5 + ripe;
  108.    return frame;
  109. }
  110. function showRipe(num)
  111. {
  112.    var ripe = getRipe(num);
  113.    _root["meat_" + num].meat_mc.gotoAndStop(ripe);
  114. }
  115. function showDirection(num)
  116. {
  117.    var direction = changeDirection(num);
  118.    _root["meat_" + num].gotoAndStop(direction);
  119.    showRipe(num);
  120. }
  121. function setSite(num, x, y)
  122. {
  123.    meat_list[num].x = x;
  124.    meat_list[num].y = y;
  125. }
  126. function getSite(num)
  127. {
  128.    _root["meat_" + num]._x = meat_list[num].x;
  129.    _root["meat_" + num]._y = meat_list[num].y;
  130. }
  131. ripeTime = 20;
  132. timeOut = 45;
  133. score_list = [0,1,10,5,0];
  134. plus_list = ["","a","c","b",""];
  135.